// Connect to the database

// Load mysql
const mysql = require('mysql');

// Export the connection configuration
module.exports = {
  config: {
    host: 'localhost',
    port: 3306,
    user: 'root',
    password: '123456',
    database: 'wvuecat'
  },
  // Connect to the database and execute SQL query
  sqlConnect: function(sql, data, callback) {
    // Create a connection pool
    const pool = mysql.createPool(this.config);

    pool.getConnection((err, connection) => {
      if (err) {
        console.log('Connection failed...' + err);
      } else {
        console.log('Connection successful...');
      }
      // Execute the SQL query
      connection.query(sql, data, callback);

      // Release the connection
      connection.release();
    });
  }
};
